<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCompanyManagement extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('company_management', function (Blueprint $table) {
            $table->unsignedBigInteger('management_id');
            $table->unsignedBigInteger('company_id');

            $table->foreign('management_id')->references('id')->on('management')
                ->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('company_id')->references('id')->on('company')
                ->onUpdate('cascade')->onDelete('cascade');

            $table->primary(['management_id', 'company_id']);
        });

        \DB::statement("ALTER TABLE `company_management` comment '公司管理员表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('company_management');
    }
}
